---
title: "Table_Regressions"
output:
  word_document: default
  html_document: default
  pdf_document: default
date: "2025-06-27"
---


```{r setup, include=FALSE}

knitr::opts_chunk$set(echo = TRUE)
#IMPORTANT: Set root directory to the folder called "MS Replication Kit Final" in the following line. Replace the path below with the path to the folder on your computer
# Example (Windows): "C:/Users/YourName/Documents/Replication Kit"
#Example (Mac): "/Users/YourName/Documents/Replication Kit"
knitr::opts_knit$set(root.dir = "")
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
```

```{r}
library(dplyr)
library(readxl)

```

```{r}
full_master <- read_excel("Data /Unique Crisis & Unique Interventions.xlsx", 
    sheet = "Unique_Crisis_Codes")
names(full_master) <- make.names(names(full_master))
```

Creating canonical and candidate data frames

```{r}
# Create candidate_crisis_final by filtering rows with Candidate = 1
candidate_crisis_final <- full_master %>%
  filter(Candidate == 1)

# Create canonical_crisis_final by filtering rows with Candidate = 0
canonical_crisis_final <- full_master %>%
  filter(Candidate == 0)
```

Table 3 (Columns without Debt/Expenditure)
```{r}
#Table 3, Column 1. Run the regression for all observations
all_obs <- lm(Gap.Sum ~ year + Log.Lagged.gdppc + Candidate + Polity + Currency.Regime, data = full_master)
summary(all_obs)

# Table 3, Column 3. Run the regression for canonical_crisis_final
canonical_model <- lm(Gap.Sum ~ year + Log.Lagged.gdppc + Polity + Currency.Regime, data = canonical_crisis_final)
summary(canonical_model)


# Table 3, Column 5. Run the regression for candidate_crisis_final
candidate_model <- lm(Gap.Sum ~ year + Log.Lagged.gdppc + Polity + Currency.Regime, data = candidate_crisis_final)
summary(candidate_model)
```

Table 3 (Columns with Debt/Expenditure)
```{r}
#Table 3, Column 2. Run the regression for all observations.
all_obs_ED <- lm(Gap.Sum ~ year + Log.Lagged.gdppc + Candidate + Polity + Currency.Regime + Exp + Debt, data = full_master)
summary(all_obs_ED)

# Table 3, Column 4. Run the regression for 
canonical_model_ED <- lm(Gap.Sum  ~ year + Log.Lagged.gdppc + Polity + Currency.Regime + Exp + Debt, data = canonical_crisis_final)
summary(canonical_model_ED)

# Table 3, Column 6. Run the regression for candidate_crisis_final
candidate_model_ED <- lm(Gap.Sum~ year + Log.Lagged.gdppc + Polity + Currency.Regime + Exp + Debt, data = candidate_crisis_final)
summary(candidate_model_ED)
```

Table 2
```{r}
library(tidyverse)
library(broom)
library(stargazer)

# List of dependent variables
dependent_vars <- c("NOI_d", "GUARANTEES_d", "LENDING_d", "CAPITAL_INJECTIONS_d",
                    "RESTRUCTURING_d", "ASSET_MANAGEMENT_d", "RULES_d", "AHLA_d", 
                    "BBLA_d", "BBAM_d", "BBCI_d", "BG_d", "OTHER_d")

for (var in dependent_vars) {
  full_master[[var]] <- ifelse(full_master[[var]] != 0, 1, 0)
}

# List to store models
model_list <- list()


# Table 2: Conduct logistic regression for each dependent variable and store in the model list
for (var in dependent_vars) {
  formula_str <- paste(var, "~ year + Log.Lagged.gdppc + Currency.Regime + Polity + Exp + Debt + Candidate")
  model <- glm(as.formula(formula_str), data=full_master, family="binomial")
  model_list[[var]] <- model
}

# Use stargazer to print all regression results side-by-side
stargazer(model_list, 
          title="Regression Results Table 2", 
          type="text", 
          align=TRUE,
          column.labels=dependent_vars)
```

Appendix C
```{r}

#Table 2.A
library(tidyverse)
library(broom)
library(stargazer)

# List of dependent variables
dependent_vars <- c("NOI_d", "GUARANTEES_d", "LENDING_d", "CAPITAL_INJECTIONS_d",
                    "RESTRUCTURING_d", "ASSET_MANAGEMENT_d", "RULES_d", "AHLA_d", 
                    "BBLA_d", "BBAM_d", "BBCI_d", "BG_d", "OTHER_d")

for (var in dependent_vars) {
  full_master[[var]] <- ifelse(full_master[[var]] != 0, 1, 0)
}

# List to store models
model_list <- list()


# Conduct logistic regression for each dependent variable and store in the model list

for (var in dependent_vars) {
  formula_str <- paste(var, "~ year + Log.Lagged.gdppc + Currency.Regime + Polity + Candidate")
  model <- glm(as.formula(formula_str), data=full_master, family="binomial")
  model_list[[var]] <- model
}

# Use stargazer to print all regression results side-by-side
stargazer(model_list, 
          title="Regression Results 2.A", 
          type="text",
          align=TRUE,
          column.labels=dependent_vars)
```

```{r}
#Table 2.B
# List of dependent variables
dependent_vars <- c("NOI_d", "GUARANTEES_d", "LENDING_d", "CAPITAL_INJECTIONS_d",
                    "RESTRUCTURING_d", "ASSET_MANAGEMENT_d", "RULES_d", "AHLA_d", 
                    "BBLA_d", "BBAM_d", "BBCI_d", "BG_d", "OTHER_d")

# List to store models
model_list <- list()

# Subset the dataframe for observations where candidate is 1
filtered_data_1 <- full_master %>% filter(Candidate == 1)

# Conduct logistic regression for each dependent variable and store in the model list
for (var in dependent_vars) {
  formula_str <- paste(var, "~ year + Log.Lagged.gdppc + Currency.Regime + Polity + Candidate")
  model <- glm(as.formula(formula_str), data=filtered_data_1, family="binomial")
  model_list[[var]] <- model
}

# Use stargazer to print all regression results side-by-side
stargazer(model_list, 
          title="Regression Results 2.B", 
          type="text", 
          align=TRUE,
          column.labels=dependent_vars)

```

```{r}
#Table 2.C
# List of dependent variables
dependent_vars <- c("NOI_d", "GUARANTEES_d", "LENDING_d", "CAPITAL_INJECTIONS_d",
                    "RESTRUCTURING_d", "ASSET_MANAGEMENT_d", "RULES_d", "AHLA_d", 
                    "BBLA_d", "BBAM_d", "BBCI_d", "BG_d", "OTHER_d")

# List to store models
model_list <- list()

# Subset the dataframe for observations where candidate is 1
filtered_data_2 <- full_master %>% filter(Candidate == 0)

# Conduct logistic regression for each dependent variable and store in the model list
for (var in dependent_vars) {
  formula_str <- paste(var, "~ year + Log.Lagged.gdppc  + Currency.Regime + Polity + Candidate")
  model <- glm(as.formula(formula_str), data=filtered_data_2, family="binomial")
  model_list[[var]] <- model
}

# Use stargazer to print all regression results side-by-side
stargazer(model_list, 
          title="Regression Results 2.C", 
          type="text", 
          align=TRUE,
          column.labels=dependent_vars)

```

```{r}
#Table 2.D
# List of dependent variables
dependent_vars <- c("NOI_d", "GUARANTEES_d", "LENDING_d", "CAPITAL_INJECTIONS_d",
                    "RESTRUCTURING_d", "ASSET_MANAGEMENT_d", "RULES_d", "AHLA_d", 
                    "BBLA_d", "BBAM_d", "BBCI_d", "BG_d", "OTHER_d")

# List to store models
model_list <- list()

# Use filtered_data_1 (Subset of dataframe for observations where candidate is 1)


# Conduct logistic regression for each dependent variable and store in the model list
for (var in dependent_vars) {
  formula_str <- paste(var, "~ year + Log.Lagged.gdppc + Currency.Regime + Polity + Exp + Debt + Candidate")
  model <- glm(as.formula(formula_str), data=filtered_data_1, family="binomial")
  model_list[[var]] <- model
}

# Use stargazer to print all regression results side-by-side
stargazer(model_list, 
          title="Regression Results 2.D", 
          type="text", 
          align=TRUE,
          column.labels=dependent_vars)

```

```{r}
#Table 2.E
# List of dependent variables
dependent_vars <- c("NOI_d", "GUARANTEES_d", "LENDING_d", "CAPITAL_INJECTIONS_d",
                    "RESTRUCTURING_d", "ASSET_MANAGEMENT_d", "RULES_d", "AHLA_d", 
                    "BBLA_d", "BBAM_d", "BBCI_d", "BG_d", "OTHER_d")

# List to store models
model_list <- list()

# Use filtered_data_2 (Subset of dataframe for observations where candidate is 0)
#filtered_data <- add_regs %>% filter(Candidate == 0)

#Conduct logistic regression for each dependent variable and store in the model list
for (var in dependent_vars) {
  formula_str <- paste(var, "~ year + Log.Lagged.gdppc + Currency.Regime + Polity + Exp + Debt + Candidate")
  model <- glm(as.formula(formula_str), data=filtered_data_2, family="binomial")
  model_list[[var]] <- model
}

# Use stargazer to print all regression results side-by-side
stargazer(model_list, 
          title="Regression Results 2.E", 
          type="text", 
          omit.stat=c("f", "adj.rsq"), 
          align=TRUE,
          column.labels=dependent_vars)

```